package com.lulu.lottiesample;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

import com.airbnb.lottie.LottieAnimationView;
import com.airbnb.lottie.LottieComposition;
import com.airbnb.lottie.LottieListener;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";
    private long startTime;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        LinearLayout linearLayout = (LinearLayout) findViewById(R.id.panel);

        findViewById(R.id.set_add).setOnClickListener(v -> {
            View inflate = LayoutInflater.from(MainActivity.this).inflate(R.layout.item, null);
            LottieAnimationView lottieAnimationView = (LottieAnimationView) inflate.findViewById(R.id.item_view);
            LottieDataLoader.getInstance().fromAssert(new LottieLoaderBean(MainActivity.this, "read.json", new LottieListener<LottieComposition>() {
                @Override
                public void onResult(LottieComposition result) {
                    lottieAnimationView.setComposition(result);
                }
            }));
            linearLayout.addView(inflate);
        });


    }
}
